home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / windows / editprog / newvisda.arj / JOIN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-03-27  |  4.8 KB  |  165 lines

  1. VERSION 2.00
  2. Begin Form fJoin 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Join Tables"
  6.    ClientHeight    =   1935
  7.    ClientLeft      =   3510
  8.    ClientTop       =   1935
  9.    ClientWidth     =   5835
  10.    ControlBox      =   0   'False
  11.    Height          =   2400
  12.    Left            =   3420
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1935
  17.    ScaleWidth      =   5835
  18.    Top             =   1560
  19.    Width           =   6015
  20.    Begin CommandButton ClearJoinsButton 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "C&lear All Joins"
  23.       Height          =   372
  24.       Left            =   2040
  25.       TabIndex        =   7
  26.       Top             =   1440
  27.       Width           =   1812
  28.    End
  29.    Begin CommandButton CloseButton 
  30.       BackColor       =   &H00C0C0C0&
  31.       Cancel          =   -1  'True
  32.       Caption         =   "&Close"
  33.       Height          =   372
  34.       Left            =   3960
  35.       TabIndex        =   6
  36.       Top             =   1470
  37.       Width           =   1812
  38.    End
  39.    Begin ListBox cFieldList2 
  40.       BackColor       =   &H00FFFFFF&
  41.       Height          =   1200
  42.       Left            =   3960
  43.       TabIndex        =   4
  44.       Tag             =   "OL"
  45.       Top             =   240
  46.       Width           =   1815
  47.    End
  48.    Begin ListBox cFieldList1 
  49.       BackColor       =   &H00FFFFFF&
  50.       Height          =   1200
  51.       Left            =   2040
  52.       TabIndex        =   3
  53.       Tag             =   "OL"
  54.       Top             =   240
  55.       Width           =   1815
  56.    End
  57.    Begin CommandButton AddJoinButton 
  58.       BackColor       =   &H00C0C0C0&
  59.       Caption         =   "&Add Join to Query"
  60.       Enabled         =   0   'False
  61.       Height          =   372
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   1440
  65.       Width           =   1812
  66.    End
  67.    Begin ListBox cTableList 
  68.       BackColor       =   &H00FFFFFF&
  69.       Height          =   1200
  70.       Left            =   120
  71.       MultiSelect     =   1  'Simple
  72.       TabIndex        =   0
  73.       Tag             =   "OL"
  74.       Top             =   240
  75.       Width           =   1815
  76.    End
  77.    Begin Label FieldsLabel 
  78.       Alignment       =   2  'Center
  79.       BackColor       =   &H00C0C0C0&
  80.       Caption         =   "Select Fields to Join Selected Tables on:"
  81.       Height          =   192
  82.       Left            =   2040
  83.       TabIndex        =   5
  84.       Top             =   0
  85.       Width           =   3732
  86.    End
  87.    Begin Label TableListLabel 
  88.       BackColor       =   &H00C0C0C0&
  89.       Caption         =   "Select Table Pair:"
  90.       Height          =   192
  91.       Left            =   120
  92.       TabIndex        =   2
  93.       Top             =   0
  94.       Width           =   1812
  95.    End
  96. Option Explicit
  97. Dim FTbl1 As String
  98. Dim FTbl2 As String
  99. Sub AddJoinButton_Click ()
  100.   Dim i As Integer
  101. 'SELECT  DISTINCTROW Categories.[Category Name], Categories.Description, Products.[Product Name], Products.[English Name]
  102. 'FROM Categories, Products,
  103. 'Categories INNER JOIN Products ON Categories.[Category ID] = Products.[Category ID];
  104.   fQuery.cJoinFields.AddItem FTbl1 + "." + "[" + cFieldList1 + "]" + "=" + FTbl2 + "." + "[" + cFieldList2 + "]"
  105.   For i = 0 To cTableList.ListCount - 1
  106.     cTableList.Selected(i) = False
  107.   Next
  108. End Sub
  109. Sub cFieldList1_Click ()
  110.   If cFieldList2 <> "" Then
  111.     AddJoinButton.Enabled = True
  112.   End If
  113. End Sub
  114. Sub cFieldList2_Click ()
  115.   If cFieldList1 <> "" Then
  116.     AddJoinButton.Enabled = True
  117.   End If
  118. End Sub
  119. Sub ClearJoinsButton_Click ()
  120.   fQuery.cJoinFields.Clear
  121. End Sub
  122. Sub CloseButton_Click ()
  123.   Unload Me
  124. End Sub
  125. Sub cTableList_Click ()
  126.   Dim i As Integer
  127.   Dim t As TableDef
  128.   FTbl1 = ""
  129.   FTbl2 = ""
  130.   cFieldList1.Clear
  131.   cFieldList2.Clear
  132.   For i = 0 To cTableList.ListCount - 1
  133.     If cTableList.Selected(i) Then
  134.       If FTbl1 = "" Then
  135.         FTbl1 = cTableList.List(i)
  136.       Else
  137.         FTbl2 = cTableList.List(i)
  138.         Exit For
  139.       End If
  140.     End If
  141.   Next
  142.   If FTbl2 = "" Then Exit Sub   'only one table selected
  143.   Set t = gCurrentDB.TableDefs(FTbl1)
  144.   For i = 0 To t.Fields.Count - 1
  145.     cFieldList1.AddItem t.Fields(i).Name
  146.   Next
  147.   Set t = gCurrentDB.TableDefs(FTbl2)
  148.   For i = 0 To t.Fields.Count - 1
  149.     cFieldList2.AddItem t.Fields(i).Name
  150.   Next
  151. End Sub
  152. Sub Form_Load ()
  153.   Dim i As Integer
  154.   For i = 0 To fQuery.cTableList.ListCount - 1
  155.     If fQuery.cTableList.Selected(i) Then
  156.       cTableList.AddItem fQuery.cTableList.List(i)
  157.     End If
  158.   Next
  159.   Top = VDMDI.Top + fQuery.Top + fQuery.cCriteria.Top + 1300
  160.   Left = fQuery.Left + 1500
  161. End Sub
  162. Sub Form_Paint ()
  163.   Outlines Me
  164. End Sub
  165.